const { Sequelize, DataTypes } = require('sequelize')
const config = require('../config/config.js')
const sequelize = new Sequelize(config)

let menuModel = sequelize.define(
  'menu',
  {
	  // 在这里定义模型属性
	  parentId: {
		  type: DataTypes.STRING,
		  comment: '上级菜单'
	  },
	  type: {
		  type: DataTypes.STRING,
		  comment: '类型'
	  },
	  icon: {
		  type: DataTypes.STRING,
		  comment: '图标'
	  },
	  name: {
		  type: DataTypes.STRING,
		  comment: '名称'
	  },
	  sort: {
		  type: DataTypes.STRING,
		  comment: '排序'
	  },
	  status: {
		  type: DataTypes.STRING,
		  comment: '状态',
		  defaultValue: '1'
	  },
	  permission: {
		  type: DataTypes.STRING,
		  comment: '授权标识'
	  },
	  path: {
		  type: DataTypes.STRING,
		  comment: '路由地址'
	  },
	  component: {
		  type: DataTypes.STRING,
		  comment: '组件地址'
	  },
	  created_time: {
		  type: Sequelize.INTEGER,
		  comment: '创建时间',
		  defaultValue: Date.parse(new Date()) / 1000
	  },
	  updated_time: {
		  type: Sequelize.INTEGER,
		  comment: '更新时间',
		  defaultValue: Date.parse(new Date()) / 1000
	  }
  },
  {
	  // 这是其他模型参数
	  timestamps: false,
	  tableName: 'menu'
  }
)

module.exports = menuModel
